var newvue = new Vue({
	el: "body",
	data: {
		shop: "",
		product: [],
		address: "",
		morry: 0
	},
	methods: {
		back: function() {
			window.history.back()
		},
		Settlement: function() {
			Settlement()
			location.href = "../index.order/index.order.html"
		}
	}
})
var href = jiLu(location.search, "orderId");
//console.log(location.search)

function jiLu(url, name) {
	c_start = url.indexOf(name + "=") //RetUrl= //1
	if(c_start != -1) {
		c_start = c_start + name.length + 1 //8
		c_end = url.indexOf("&", c_start) //16
		if(c_end == -1) c_end = url.length
		return unescape(url.substring(c_start, c_end))
	}
	return ""
}
var par
window.onload = function() {
	var APP_ID = 'c4w6bVvWfh8xxcmkBE1G0gIt-gzGzoHsz';
	var APP_KEY = 'JBikg4Ksk76zcTi5BKYWvTJF';
	AV.init({
		appId: APP_ID,
		appKey: APP_KEY
	});

	var query = new AV.Query('ELM_order');
	query.get(href).then(function(todo) {
			console.log(todo)
			    par = todo.attributes.if_pay
					var obj = {
						shopname: todo.attributes.shop_name,
						shopimg: todo.attributes.shopimg,
						price: todo.attributes.shop_sendprice,
						total: todo.attributes.totle
					}
					var arr = todo.attributes.products_data
					newvue.shop = obj
					console.log(newvue.shop)
					newvue.morry = todo.attributes.totle * 1 + todo.attributes.shop_sendprice * 1
	
				for(var i = 0; i < arr.length; i++) {
					var objs = {
						productname: arr[i].name,
						productnum: arr[i].num,
						productprice: arr[i].price
					}
					newvue.product.push(objs)
				}
		},
		function(error) {
			// 异常处理
		});
}

function Settlement() {
	// 第一个参数是 className，第二个参数是 objectId
	var todo = AV.Object.createWithoutData('ELM_order', href);
	// 修改属性
	todo.set('if_pay', true);
	// 保存到云端
	todo.save();
}